//引用nodemailer插件
var nodemailer = require('nodemailer');
//引用证书文件
var creditials = require('../config/credentials.js');

//创建传输方式
var transporter = nodemailer.createTransport({
	service: 'qq',
	auth: {
		user: creditials.qq.user,
		pass: creditials.qq.pass
	}
});

//注册发送邮箱
exports.emailSignUp = function(email, name, res) {
	//发送信息
	var options = {
		from: '文轩阁官方',
		to: email,
		subject: '注册成功！',
		html: `<h1 style="color:red">亲爱的 ${name} 用户, 感谢您的注册！</h1><h2>感谢注册！</h2>`
	};

	//发送
	transporter.sendMail(options, function(err, msg) {
		if (err) {
			console.log(err);
			res.send(err)
		} else {
			console.log('成功')
			res.send('发送成功')
		}
	})
}
